Objective C Insanity -- simple assignement to a single float variable results in {{{CRAZY}}} values

Posted by morgancodes on Stack Overflow See other posts from Stack Overflow or by morgancodes
Published on 2010-03-16T22:35:11Z Indexed on 2010/03/16 22:41 UTC
Read the original article Hit count: 340

Filed under:
|

memberA is defined in the header of ClassA.

memberB is defined in the header of ClassB.

ClassB is a subclass of ClassA

Inside an instance of ClassB, setting memberA via simple assignment:

memberA = 0.05

...also changes memberB, but to a crazy number -- 1028443341. Additionally, assigning 0.05 to memberA results in memberA showing up in the debugger as 5.33083531e-38.

Both variables are floats, neither is a pointer. I'm almost certianly making some noob mistake, but I don't have any clue what it might be. What sort of screw-up might make it so assigning a value to one variable results in crazy values appearing in two variables?

I can give more details or real code, but figured I'd keep it simple to start with in case it's an obvious problem/solution.

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about madness

  • How to Watch NCAA March Madness Online

    as seen on How to geek - Search for 'How to geek'
    You’ve filled out your brackets and now you are ready for one of America’s most popular sporting events. But what if you are you stuck at work or away from your TV?  Or your local affiliate is showing a different game? Today we show how to catch all the March Madness online. March Madness on… >>> More

  • Dependency Injection Constructor Madness

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I find that my constructors are starting to look like this: public MyClass(Container con, SomeClass1 obj1, SomeClass2, obj2.... ) with ever increasing parameter list. Since "Container" is my dependency injection container, why can't I just do this: public MyClass(Container con) for every class… >>> More

  • MVVM Madness: Commands

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I like MVVM. I don't love it, but like it. Most of it makes sense. But, I keep reading articles that encourage you to write a lot of code so that you can write XAML and don't have to write any code in the code-behind. Let me give you an example. Recently I wanted to hookup a command in my ViewModel… >>> More

  • Ruby metaclass madness

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I'm stuck. I'm trying to dynamically define a class method and I can't wrap my head around the ruby metaclass model. Consider the following class: class Example def self.meta; (class << self; self; end); end def self.class_instance; self; end end Example.class_instance.class # =>… >>> More

  • UITableView madness

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Hello, I'm new to iPhone application development. I'm trying to understand how to use UITableView. I'm wrote simple code: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section… >>> More